package com.syni.mdd.yhd.common.all.service.impl.system;

import com.syni.mdd.yhd.common.all.constants.ResultMsg;
import com.syni.mdd.yhd.common.all.dao.jpa.BmsBusinessCouponDao;
import com.syni.mdd.yhd.common.all.dao.jpa.system.BmsDxVersionDao;
import com.syni.mdd.yhd.common.all.entity.system.BmsDxVersion;
import com.syni.mdd.yhd.common.all.service.BmsCommonService;
import com.syni.mdd.yhd.common.all.service.BmsDxVersionService;
import com.syni.mdd.sjb.common.component.utils.common.utils.ParamsMap;
import com.syni.mdd.sjb.common.component.utils.common.utils.ResultMapHelper;
import com.syni.mdd.yhd.common.all.utils.SpecificationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @className BmsDxVersionServiceImpl
 * @description TOO
 * @Author cfx
 * @DATE 2019/11/5 15:20
 * @VERSION 1.0
 **/
@Service
public class BmsDxVersionServiceImpl implements BmsDxVersionService {
    @Autowired
    BmsDxVersionDao bmsDxVersionDao;
    @Override
    public BmsDxVersionDao getBaseDao() {
        return bmsDxVersionDao;
    }

    @Override
    public Map<String, Object> getVersion(ParamsMap paramsMap) {
        Integer client = paramsMap.getInteger("client");
        Integer from = paramsMap.getInteger("from");
        Map<String,Object> conditionMap = new HashMap<>();
        conditionMap.put("client",client);
        conditionMap.put("from",from);
        Pageable pageable = BmsCommonService.getPageable(1,1, Sort.Direction.DESC,"newTime");
        Page page = bmsDxVersionDao.findAll(new SpecificationUtils(conditionMap),pageable);
        List<BmsDxVersion> bmsDxVersionList = page.getContent();
        return ResultMapHelper.success(bmsDxVersionList, ResultMsg.MSG_GET_SUCCESS);
    }
}
